using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using CastleDefender.ConfigFolder;


namespace CastleDefender.Object.Monsters
{
    public class MonsterFly : Monster
    {
        #region VARIABLE
        protected float fltRate;
        #endregion

        #region CONSTRUCTION
        public MonsterFly(Game myGame, ref Texture2D texture, int widthframe, int heightframe, int life,int type, int speed, Vector2 target, Vector2 position)
            : base(myGame, ref texture, widthframe, heightframe,type, life, speed, position)
        {
            intMoveStep = Config.MonsterMoveStepNormal;
            vecTarget = target;
            SetRate();
        }
        #endregion

        #region PUBLIC METHOD

        protected override void Move()
        {
            float posX = vecPosition.X + intMoveStep * intDirection;
            float posY = vecPosition.Y + intMoveStep * fltRate;
            vecPosition = new Vector2(posX, posY);
            CheckPosition();

            base.Move();
        }

        protected void SetRate()
        {
            var delta = vecTarget - vecPosition;
            fltRate = Math.Abs(delta.Y / delta.X);
        }
        #endregion
    }
}
